<?php
$id = getInput("id",0);
$offset = getInput("offset",0);
$limit = getInput("limit",10);

$benefit = new Benefit($id);

$category = new Category();
$categories = $category->getAll("name asc");

$content = loadView("benefit/edit", array("entity" => $benefit, "categories" => $categories));

$benefitManager = new Benefit();

$entities = $benefitManager->getAll("name asc", $limit, $offset, 0, false);
$count = $benefitManager->getAll("name asc", $limit, $offset, true);

$editUrl = WWWROOT . "admin/benefits.php?id=";

$content .=loadView("benefit/list", array("entities" => $entities, "editUrl" => $editUrl));

$content .=  loadView("navigation/pagination", array("offset" => $offset, "limit" => $limit, "count" => $count));

echo loadTemplate("top_menu", langEcho("crud_benefits"), array("main" => $content));
?>